<h2>Список организаций</h2>

<ul id="menu">
	<% if logged_in? %>
	<li>
		<%= link_to "Добавить +", new_organization_path %>
	</li>
	<% end %>

	<li>
		<%= link_to "Найти", :action => "search" %>
	</li>
</ul>
	
<table id="organizations" width="100%" cellspacing="1" cellpadding="0">
    <% for organization in @organizations %>
		<tr>
			<td width="70%">
				<%= link_to organization.russian_title, :action => "show", :id => organization.id %>
				<% if not organization.foreign_title.empty? %>
					<% unless organization.russian_title.empty? %>
						(<%= link_to organization.foreign_title, :action => "show", :id => organization.id %>)
					<% else %>
						<%= link_to organization.foreign_title, :action => "show", :id => organization.id %>
					<% end %>
				<% end %>
			</td>
			
			<td>
				<% if logged_in? and (current_user.role == 1 or organization.user.id == current_user.id )%>		
					<%= link_to "Редактировать", edit_organization_path(organization.id) %>
					<%= link_to "Удалить", :action => "destroy", :id => organization.id %>
				<% end %>
			</td>
		</tr>
	<% end %>
</table>